import {Component,OnInit,ViewChild} from '@angular/core';
import { PageModel } from "../../../../model/page-model";
import { ModalDirective } from 'ng2-bootstrap/modal';
import { flyIn } from '../../../../animations/fly-in';
import { MyHttp } from '../../../../service/MyHttp';

@Component({
  selector: 'generalusers',
  templateUrl: './generalusers.component.html',
  styleUrls: ['./generalusers.component.css'],
  animations: [
    flyIn
  ]
})
export class Generalusers implements OnInit{
  @ViewChild('myModal') public myModal:ModalDirective;
  pageModel = new PageModel();
  page:number = 1;
  oldpassword:any;
  newpassword:any;
  comfirmpassword:any;
  userdata:any;
  btype:number;
  usertelephone:number;
  constructor(private myHttp:MyHttp) {}
  ngOnInit() {   
    this.getData();
  }
  cancel(){
    this.oldpassword='';
    this.newpassword='';
    this.comfirmpassword='';
  }

  getData(){
    this.myHttp.post('user/findByPage?page='+this.page,{}).subscribe(res=>{
      //console.log(res)
      if(res.errorCode==0){
        this.userdata = res.message.data;      
        this.pageModel.setPage({'iTotalRecords':res.message.total});
      }
     
    },err=>console.log(err));
  }

  getSearchdata(){
    this.myHttp.post('user/findByTel',{"user_telephone" :this.usertelephone}).subscribe(res=>{
      //console.log(res)
      if(res.errorCode==0){
        this.userdata = [res.message]; 
      }
     
    },err=>console.log(err)); 
  }
  

}

